<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        /* 创建一个时间对象 */
        var d = new Date();
        /* 可以设置 */
        d.setFullYear(2021)

        //获取年
        var year = d.getFullYear();
        //获取月
        var mon = d.getMonth()+1;
        //获取日
        var date = d.getDate();
        //获取时
        var hou = d.getHours();
        //获取分
        var min = d.getMinutes();
        //获取秒
        var sec = d.getSeconds();
        //获取周
        var week = d.getDay();

        //使用模板字符串将他们拼接在一起
        var str = `现在是:${year}年,${mon}月,${date}日,${hou}时,${min}分,${sec}秒`
        document.write(str)

    </script>
</body>
</html>